package aufgabe1;

import java.util.Comparator;



public class TestDriver1 {

	static ArrayReader arrReader = new ArrayReader(
			"C:\\Users\\Benny\\Desktop\\array.txt");

	public static void main(String[] args) {

		initReader();

		//initBinTree();
		testBinarySearchTree();

	}

	private static void initBinTree() {

		BinaryTree<Integer> binTree = new BinaryTree<Integer>();

		for (int i = 0; i <= arrReader.getText().size() - 1; i++) {
			binTree.addValue(arrReader.getText().get(i));

		}
		System.out.println("Nodes: " + binTree.nodes());
        System.out.println("Leafs: " + binTree.leaves());
        System.out.println("Depth: " + binTree.depth());
        binTree.showTreeGraphic("binTree");
		
	}
	private static void testBinarySearchTree(){
		BinarySearchTree<Integer> bs2 = new BinarySearchTree<Integer>(new IntegerComparator());
        bs2.addValue(new Integer(9));
        bs2.addValue(new Integer(2));
        bs2.addValue(new Integer(10));
        bs2.addValue(new Integer(1));
        bs2.addValue(new Integer(7));
        bs2.addValue(new Integer(5));
        bs2.addValue(new Integer(8));
        bs2.addValue(new Integer(6));
        bs2.addValue(new Integer(3));
        bs2.addValue(new Integer(4));
        bs2.addValue(new Integer(14));
        bs2.addValue(new Integer(14));
        bs2.addValue(new Integer(12));
        bs2.addValue(new Integer(15));
        bs2.addValue(new Integer(13));
        bs2.addValue(new Integer(16));
        bs2.showTreeGraphic("bs2");
        System.out.println("  nodes: " + bs2.nodes());
        System.out.println("  leaves: " + bs2.leaves());
        System.out.println("  depth: " + bs2.depth());

        bs2.delValue(new Integer(13));
        System.out.println("  nodes: " + bs2.nodes());
        System.out.println("  leaves: " + bs2.leaves());
        System.out.println("  depth: " + bs2.depth());
        bs2.showTreeGraphic("bs2 - del 13");

        bs2.delValue(new Integer(14));
        System.out.println("  nodes: " + bs2.nodes());
        System.out.println("  leaves: " + bs2.leaves());
        System.out.println("  depth: " + bs2.depth());
        bs2.showTreeGraphic("bs2 - del 14");

        bs2.delValue(new Integer(2));
        System.out.println("  nodes: " + bs2.nodes());
        System.out.println("  leaves: " + bs2.leaves());
        System.out.println("  depth: " + bs2.depth());
        bs2.showTreeGraphic("bs2 - del 2");

        bs2.delValue(new Integer(9));
        System.out.println("  nodes: " + bs2.nodes());
        System.out.println("  leaves: " + bs2.leaves());
        System.out.println("  depth: " + bs2.depth());
        bs2.showTreeGraphic("bs2 - del 9");

        bs2.delValue(new Integer(10));
        System.out.println("  nodes: " + bs2.nodes());
        System.out.println("  leaves: " + bs2.leaves());
        System.out.println("  depth: " + bs2.depth());
        bs2.showTreeGraphic("bs2 - del 10");

        bs2.delValue(new Integer(16));
        System.out.println("  nodes: " + bs2.nodes());
        System.out.println("  leaves: " + bs2.leaves());
        System.out.println("  depth: " + bs2.depth());
        bs2.showTreeGraphic("bs2 - del 16");

        bs2.delValue(new Integer(15));
        System.out.println("  nodes: " + bs2.nodes());
        System.out.println("  leaves: " + bs2.leaves());
        System.out.println("  depth: " + bs2.depth());
        bs2.showTreeGraphic("bs2 - del 15");

        bs2.delValue(new Integer(12));
        System.out.println("  nodes: " + bs2.nodes());
        System.out.println("  leaves: " + bs2.leaves());
        System.out.println("  depth: " + bs2.depth());
        bs2.showTreeGraphic("bs2 - del 12");


	}
	public static void initReader() {

		System.out.println(arrReader.getText());
		System.out.println(arrReader.getText().size());

	}
}
